const JWT = require('jsonwebtoken');
const SECRET = "lovestarboy";

const createToken = (username) => {
    let token = JWT.sign({
        user: username
    }, SECRET, {
        expiresIn: "4 hours"
    })
    return token;
}

const verifyToken = (_token) => {
    let verify = JWT.verify(_token, SECRET, (err, decoded) => {
        if (err) {
            return "Token Invalid";
        }
        return decoded
    })
    return verify
}

module.exports = {
    createToken,
    verifyToken
}